package com.geekaca.d3.whilehomework;

import java.util.Random;
import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
        Random random = new Random();
        int randNum = random.nextInt(100);
        randNum += 1;
        Scanner scanner = new Scanner(System.in);
        int count =0;
        while (true) {
            System.out.println("请猜一下这个数(四次机走): ");
            int guessNum = scanner.nextInt();

            if (randNum == guessNum) {
                System.out.println("恭喜你,猜中了.");
                System.out.println("程序退出...");
                break;
            } else if (randNum > guessNum) {
                System.out.println("你猜的数小了.");
            } else {
                System.out.println("你猜的数大了");
            }

            count++;
            if(count>=4){
                System.out.println("达到最大次数4次,游戏结束.");
                break;
            }

            System.out.println("guess what I did");
        }

    }
}
